import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEActionInput } from './ipsdeaction-input';
import { IPSDEActionParam } from './ipsdeaction-param';
import { IPSDEField } from '../defield/ipsdefield';
import { IPSDEMethodDTO } from '../service/ipsdemethod-dto';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEActionInputImpl extends PSModelObjectImpl implements IPSDEActionInput {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected keypsdefield: IPSDEField | null = null;

  getKeyPSDEField(): IPSDEField | null {
    if (this.keypsdefield != null) return this.keypsdefield;
    const value = this.M.getKeyPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.keypsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.keypsdefield;
  }

  get keyPSDEField(): IPSDEField | null {
    return this.getKeyPSDEField();
  }

  getKeyPSDEFieldMust(): IPSDEField {
    const value = this.getKeyPSDEField();
    if (value == null) {
      throw new Error('未指定主键属性对象');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdeactionparams: IPSDEActionParam[] | null = null;

  getPSDEActionParams(): IPSDEActionParam[] | null {
    if (this.psdeactionparams == null) {
      this.psdeactionparams = this.fillChildListModel(this.M.getPSDEActionParams, 'dataentity.action.IPSDEActionParam') as IPSDEActionParam[];
    }
    return this.psdeactionparams;
  }

  get psDEActionParams(): IPSDEActionParam[] | null {
    return this.getPSDEActionParams();
  }

  findPSDEActionParam(objKey: any): IPSDEActionParam | null {
    return this.getPSModel5('dataentity.action.IPSDEActionParam', this.getPSDEActionParams(), objKey) as IPSDEActionParam;
  }

  protected psdemethoddto: IPSDEMethodDTO | null = null;

  getPSDEMethodDTO(): IPSDEMethodDTO | null {
    if (this.psdemethoddto != null) return this.psdemethoddto;
    const value = this.M.getPSDEMethodDTO;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdemethoddto = ipsdataentity.findPSDEMethodDTO(value);
    }
    return this.psdemethoddto;
  }

  get psDEMethodDTO(): IPSDEMethodDTO | null {
    return this.getPSDEMethodDTO();
  }

  getPSDEMethodDTOMust(): IPSDEMethodDTO {
    const value = this.getPSDEMethodDTO();
    if (value == null) {
      throw new Error('未指定实体方法DTO对象');
    }
    return value;
  }

  get type(): 'NONE' | 'KEYFIELD' | 'KEYFIELDS' | 'DTO' | 'DTOS' | 'FILTER' | 'UNKNOWN' | 'USER' | 'USER2' {
    return this.M.type;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get output(): boolean {
    return this.M.output != null ? this.M.output : false;
  }

  get cls(): string {
    return 'PSDEActionInputImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.action.IPSDEActionInput' || cls == 'dataentity.service.IPSDEMethodInput') return true;
    return super.instanceof(cls);
  }
}
